Skip to content

feat(targets): import 70 H7 boards; full flash define audit#1233

Merged
nerdCopter merged 15 commits into
emuflight:masterfrom
nerdCopter:feat/target-updates
Jun 4, 2026
Merged

feat(targets): import 70 H7 boards; full flash define audit#1233
nerdCopter merged 15 commits into
emuflight:masterfrom
nerdCopter:feat/target-updates

Conversation

@nerdCopter
Copy link
Copy Markdown
Member

AI Generated pull-request

Summary

  • Import 70 H7 board targets from the feat/stm32h7-support branch backup (KAKUTEH7*, MAMBAH743*, MATEKH743, FOXEERH743*, GEPRC_TAKER_H743*, IFLIGHT_H743_AIO*, JHEH743*, DARWINH7DUAL, and 55 others). Each has target.c timer pin maps, USED_TIMERS, and flash defines sourced from the stm32h7-support branch.
  • STELLARH7DEV: re-enable USE_FLASH_W25M02G — previously disabled pending feat(h7/nand): non-blocking W25N NAND erase state machine for STELLARH7DEV #1209; fixed in fix(flash/nand): NAND flash fixes; re-enable W25M02G on STELLARH7DEV #1231.
  • Flash define audit against BF 4.5 unified-target configs (config/configs/) across all 378 targets:
    • 53 F4/F7 targets: add USE_FLASH_W25Q128FV alongside USE_FLASH_M25P16 (chip identifier, BF 4.5 parity)
    • 6 F4/F7 targets: add missing NAND flash defines (W25N01G, W25M512) — CLRACINGF7, IFLIGHT_F405/F722/F745_TWING, JHEF405PRO, NBD_INFINITYAIO255
    • ALIENFLIGHTNGF7: replace M25P16 with W25N01G; fix symbolic CS pin to PB12
    • FPVM_BETAFLIGHTF7, PYRODRONEF4PDB: add complete flash config (was entirely absent)
    • MATEKF722HD: remove dead USE_FLASH_W25M; upgrade to USE_FLASH_W25Q128FV
    • Several targets: remove testing-tagged dead defines (W25M, W25Q, W25P16 typo)
    • ZEEZF7: clean to W25N01G-only per BF configs
    • 4 targets: fix ONBOARDFLASH/chip-define mismatches (SPEEDYBEEF7V3, PYRODRONEF4PDB, VRRACE, OMNIBUSF4V6)
    • 15 targets: add chip define + CS/SPI pins (had ONBOARDFLASH in .mk but no defines in .h)
    • 15 targets: remove phantom ONBOARDFLASH (no flash hardware per BF configs — converter default noise)
    • 3 H7 NAND targets (IFLIGHT_H7_TWING, NEUTRONRCH743AIO, NEUTRONRCH7BT): chip defines match BF configs; CS/SPI absent in BF configs too

Test plan

  • Build passes: STELLARH7DEV (H743, W25M02G NAND flash)
  • Build passes: representative F4 target with W25Q128FV (e.g. KAKUTEF4)
  • Build passes: representative F7 target with W25N01G (e.g. CLRACINGF7)
  • Build passes: representative H7 target from newly imported set (e.g. KAKUTEH7V2, MAMBAH743)
  • Hardware verified: n/a for target-file-only changes; flash hardware verification covered by fix(flash/nand): NAND flash fixes; re-enable W25M02G on STELLARH7DEV #1231

nerdCopter and others added 5 commits June 1, 2026 15:44
…arity

AI Generated feat

H7 targets (70 new boards imported from stm32h7-support branch backup):
- Import 70 STM32H743/H750/H7xx board targets not yet in master: includes
  KAKUTEH7*, MAMBAH743*, MATEKH743, DARWINH7DUAL, FOXEERH743*, GEPRC_TAKER_H743*,
  IFLIGHT_H743_AIO*, JHEH743*, and 55 others. All have target.c timer pin maps,
  USED_TIMERS, and flash defines sourced from feat/stm32h7-support branch.
- STELLARH7DEV: re-enable USE_FLASH_W25M02G (W25M02G NAND flash); emuflight#1209 fixed
  via async erase path; emuflight#1228 NAND driver bugs fixed.
- Three H7 targets (IFLIGHT_H7_TWING, NEUTRONRCH743AIO, NEUTRONRCH7BT) have
  NAND chip defines but missing FLASH_CS_PIN/FLASH_SPI_INSTANCE — marked with
  TODO comments pending hardware research.

Flash define updates (BF 4.5 parity, F4/F7/H7 existing targets):
- 53 F4/F7 targets: add USE_FLASH_W25Q128FV alongside existing USE_FLASH_M25P16
  (W25Q128FV = chip identifier; M25P16 driver handles SPI; W25Q128FV enables
  QuadSPI optimised path when USE_QUADSPI is defined). Matches BF 4.5 configs.
- ALIENFLIGHTNGF7: replace USE_FLASH_M25P16 with USE_FLASH_W25N01G + update
  FLASH_CS_PIN from symbolic SPI2_NSS_PIN to explicit PB12 per BF configs.
- CLRACINGF7: add USE_FLASH_W25Q128FV + USE_FLASH_W25N01G alongside M25P16.
- IFLIGHT_F405_TWING, IFLIGHT_F745_AIO, JHEF405PRO: add USE_FLASH_W25N01G.
- IFLIGHT_F722_TWING: add USE_FLASH_W25M512 + USE_FLASH_W25N01G.
- NBD_INFINITYAIO255: add USE_FLASH_W25N01G (was missing; BF configs has it).
- FPVM_BETAFLIGHTF7: add complete flash config (W25Q128FV, CS=PE4, SPI4);
  fully missing in EF; sourced from BF configs.
- PYRODRONEF4PDB: add complete flash config (W25Q128FV, CS=PC13, SPI2).
- SPEEDYBEEF7V3: add USE_FLASH_M25P16 (pins were present, driver define
  commented out with stale "breaks CLI" note; BF configs confirms flash present).
- MATEKF722HD: remove dead USE_FLASH_W25M; replace M25P16 with W25Q128FV per BF.
- MATEKF722PX: remove dead USE_FLASH_W25M.

Testing cruft removed (dead #defines compiling in unused driver code):
- CYCLONEF722_PRO: remove USE_FLASH_W25P16 typo.
- MAMBAF405_2022B: remove 4 //testing lines (W25M, W25M512, W25Q, dup M25P16).
- NBD_INFINITYAIOV2PRO: remove 4 //testing lines.
- ZEEZF7: remove USE_FLASH and explicit USE_FLASHFS (auto-derived); remove dead
  USE_FLASH_W25M, USE_FLASH_W25M512, USE_FLASH_W25Q; remove extra M25P16
  (board is NAND-only per BF configs — W25N01G driver, not M25P16).
- ZEEZF7V2: remove dead USE_FLASH_W25M.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AI Generated fix

source.mk gates ALL flash driver sources behind the ONBOARDFLASH feature
flag — flash.c, flash_m25p16.c, flash_w25m.c, flash_w25n.c,
flash_w25q128fv.c, and flashfs.c are only compiled when FEATURES includes
ONBOARDFLASH. Having chip-specific defines in target.h without ONBOARDFLASH
in target.mk means the defines resolve at the preprocessor but no flash
driver code is linked — flash silently never initialises.

Three targets had flash chip defines in target.h but were missing ONBOARDFLASH
in their target.mk FEATURES line:

- SPEEDYBEEF7V3 (F7X2RE): had USE_FLASH_M25P16 + FLASH_CS/SPI_INSTANCE but
  only FEATURES += VCP SDCARD; flash sources were never compiled.
  Fixed: add ONBOARDFLASH alongside SDCARD (board has both SD card and SPI
  flash).

- PYRODRONEF4PDB (F405): had full flash config (USE_FLASH_W25Q128FV +
  USE_FLASH_M25P16 + FLASH_CS_PIN + FLASH_SPI_INSTANCE) added in the
  previous commit but FEATURES was left as `VCP` only.
  Fixed: add ONBOARDFLASH.

- VRRACE (F405): had USE_FLASH_M25P16 + FLASH_CS/SPI_INSTANCE but
  FEATURES += VCP only.
  Fixed: add ONBOARDFLASH.

One target had the opposite problem — ONBOARDFLASH in target.mk but no chip
define or pin assignments in target.h:

- OMNIBUSF4V6 (F405): FEATURES already had ONBOARDFLASH so flash sources
  compiled, but common_fc_post.h had nothing to work with — USE_FLASH,
  USE_FLASH_M25P16, FLASH_CS_PIN, and FLASH_SPI_INSTANCE were all absent,
  so flashInit() was never triggered. BF unified-target configs confirm
  M25P16 at CS=PB12/SPI2 with DEFAULT_BLACKBOX_DEVICE_FLASH.
  Fixed: add USE_FLASH_M25P16 + FLASH_CS_PIN PB12 + FLASH_SPI_INSTANCE SPI2
  + ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… truth

AI Generated fix

Three H7 targets with NAND flash chip defines but missing FLASH_CS_PIN
and FLASH_SPI_INSTANCE were marked with TODO comments asking for
"hardware research". Verified against BF 4.5 unified-target configs
(~/SYNC/nerdCopter-GIT/config/configs/) — all three targets also lack
FLASH_CS_PIN/FLASH_SPI_INSTANCE in BF's own config.h files:

- IFLIGHT_H7_TWING: BF config has USE_FLASH + USE_FLASH_M25P16 +
  USE_FLASH_W25N01G + DEFAULT_BLACKBOX_DEVICE_FLASH, no CS/SPI pins.
- NEUTRONRCH743AIO: BF config has USE_FLASH + USE_FLASH_W25N01G only.
- NEUTRONRCH7BT: BF config has USE_FLASH + USE_FLASH_W25N01G only.

The chip defines in the EF target files already match BF configs
exactly. Replace the TODO blocks (which implied EF-specific ignorance
and suggested external hardware research) with a single-line note
pointing to BF configs as the upstream authoritative source. No
functional change — chip defines, pins, and ONBOARDFLASH feature flag
are all unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AI Generated fix

Two categories of pre-existing flash misconfiguration corrected using
BF 4.5 unified-target configs (config/configs/) as authoritative source.

--- Group A: 15 targets — add chip define + pins (real flash, config missing)

These targets had ONBOARDFLASH in target.mk so flash sources compiled,
but target.h had no chip define, no FLASH_CS_PIN, and no FLASH_SPI_INSTANCE.
flashInit() was called but the device could never be identified or driven.
BF configs confirms flash hardware on all 15.

Added USE_FLASH_M25P16 + FLASH_CS_PIN + FLASH_SPI_INSTANCE (from BF configs)
to each target.h. Also added ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT
where BF configs has DEFAULT_BLACKBOX_DEVICE_FLASH.

  EXUAVF4PRO    CS=PB3  SPI3  bblog=yes
  XRACERF4      CS=PB3  SPI3  bblog=yes
  EACHINEF722_AIO  CS=PD2  SPI3  bblog=yes
  NBD_CRICKETF7 CS=PA4  SPI1  bblog=no
  MERAKRCF405   CS=PA4  SPI1  bblog=yes
  GEELANGF411   CS=PB3  SPI2  bblog=yes
  PODIUMF4      CS=PB3  SPI3  bblog=no
  SOULF4        CS=PB3  SPI3  bblog=no
  ELINF405      CS=PB3  SPI3  bblog=no
  DYSF44530D    CS=PC0  SPI3  bblog=yes
  EACHINEF411_AIO  CS=PA15 SPI2  bblog=yes
  PYRODRONEF7   CS=PB12 SPI2  bblog=yes
  FLYWOOF411HEX CS=PB2  SPI2  bblog=yes
  PLUMF4        CS=PA15 SPI3  bblog=no
  MERAKRCF722   CS=PA4  SPI1  bblog=yes

--- Group B: 15 targets — remove ONBOARDFLASH (no flash hardware)

These targets had FEATURES += ... ONBOARDFLASH despite having no flash
hardware in BF configs (no FLASH_CS_PIN, no chip define, no USE_FLASH).
The ONBOARDFLASH was added by the convert.sh default: any target without
SDCARD previously got ONBOARDFLASH regardless of whether it had flash.
This compiled ~20–30 KB of flash driver and MSC source code that served
no function.

  HELSEL_STRIKERF7, ATOMRCF411, TRANSTECF411AIO, TRANSTECF411,
  TRANSTECF7, STM32F411DISCOVERY, FF_PIKOF4OSD, REVONANO,
  NBDBBBLV3, NBDBBBLV2, IFLIGHT_BLITZ_F411RX, NBD_CRICKETF7V2,
  TRANSTECF411HD, FF_FORTINIF4_REV03, HAKRCF411

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 2, 2026

Important

Review skipped

Too many files!

This PR contains 300 files, which is 150 over the limit of 150.

To get a review, narrow the scope:
• coderabbit review --type committed # exclude uncommitted changes
• coderabbit review --dir # limit to a subdirectory
• coderabbit review --base # compare against a closer base

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1ed34d14-c282-405f-b023-ae794c980a7b

📥 Commits

Reviewing files that changed from the base of the PR and between afc8c85 and 701eabf.

📒 Files selected for processing (300)
  • src/main/target/2RAW_THUNDER_H7/target.c
  • src/main/target/2RAW_THUNDER_H7/target.h
  • src/main/target/2RAW_THUNDER_H7/target.mk
  • src/main/target/ACROSKYH743/target.c
  • src/main/target/ACROSKYH743/target.h
  • src/main/target/ACROSKYH743/target.mk
  • src/main/target/AEDROXH7/target.c
  • src/main/target/AEDROXH7/target.h
  • src/main/target/AEDROXH7/target.mk
  • src/main/target/AEROH7DIGITAL/target.c
  • src/main/target/AEROH7DIGITAL/target.h
  • src/main/target/AEROH7DIGITAL/target.mk
  • src/main/target/AIRBOTF7/target.h
  • src/main/target/AIRBRAINH743/target.c
  • src/main/target/AIRBRAINH743/target.h
  • src/main/target/AIRBRAINH743/target.mk
  • src/main/target/AIRF7/target.h
  • src/main/target/ALIENFLIGHTNGF7/target.h
  • src/main/target/AOCODAF722MINI/target.h
  • src/main/target/AOCODARCH7DUAL/target.c
  • src/main/target/AOCODARCH7DUAL/target.h
  • src/main/target/AOCODARCH7DUAL/target.mk
  • src/main/target/APEXF7/target.h
  • src/main/target/ATOMRCF411/target.mk
  • src/main/target/AXISFLYINGF7/target.h
  • src/main/target/AXISFLYINGH743PRO/target.c
  • src/main/target/AXISFLYINGH743PRO/target.h
  • src/main/target/AXISFLYINGH743PRO/target.mk
  • src/main/target/BETAFLIGHTF4/target.h
  • src/main/target/BETAFPVF405/target.h
  • src/main/target/BETAFPVF411RX/target.h
  • src/main/target/BETAFPVF722/target.h
  • src/main/target/BETAFPVH725/target.c
  • src/main/target/BETAFPVH725/target.h
  • src/main/target/BETAFPVH725/target.mk
  • src/main/target/BETAFPVH743/target.c
  • src/main/target/BETAFPVH743/target.h
  • src/main/target/BETAFPVH743/target.mk
  • src/main/target/BROTHERHOBBYH743/target.c
  • src/main/target/BROTHERHOBBYH743/target.h
  • src/main/target/BROTHERHOBBYH743/target.mk
  • src/main/target/CHAMP_H743ICM/target.c
  • src/main/target/CHAMP_H743ICM/target.h
  • src/main/target/CHAMP_H743ICM/target.mk
  • src/main/target/CHAMP_H743MPU/target.c
  • src/main/target/CHAMP_H743MPU/target.h
  • src/main/target/CHAMP_H743MPU/target.mk
  • src/main/target/CLRACINGF7/target.h
  • src/main/target/CYCLONEF722_PRO/target.h
  • src/main/target/DAKEFPVH743/target.c
  • src/main/target/DAKEFPVH743/target.h
  • src/main/target/DAKEFPVH743/target.mk
  • src/main/target/DAKEFPVH743PRO/target.c
  • src/main/target/DAKEFPVH743PRO/target.h
  • src/main/target/DAKEFPVH743PRO/target.mk
  • src/main/target/DAKEFPVH743_SLIM/target.c
  • src/main/target/DAKEFPVH743_SLIM/target.h
  • src/main/target/DAKEFPVH743_SLIM/target.mk
  • src/main/target/DALRCF405/target.h
  • src/main/target/DALRCF722DUAL/target.h
  • src/main/target/DARWINF722HD/target.h
  • src/main/target/DARWINH7DUAL/target.c
  • src/main/target/DARWINH7DUAL/target.h
  • src/main/target/DARWINH7DUAL/target.mk
  • src/main/target/DREAMWORKSH743/target.c
  • src/main/target/DREAMWORKSH743/target.h
  • src/main/target/DREAMWORKSH743/target.mk
  • src/main/target/DRONEERH743DUAL/target.c
  • src/main/target/DRONEERH743DUAL/target.h
  • src/main/target/DRONEERH743DUAL/target.mk
  • src/main/target/DYSF44530D/target.h
  • src/main/target/EACHINEF411_AIO/target.h
  • src/main/target/EACHINEF722_AIO/target.h
  • src/main/target/ELINF405/target.h
  • src/main/target/EXUAVF4PRO/target.h
  • src/main/target/FF_FORTINIF4/target.h
  • src/main/target/FF_FORTINIF4_REV03/target.mk
  • src/main/target/FF_PIKOF4/target.h
  • src/main/target/FF_PIKOF4OSD/target.mk
  • src/main/target/FF_RACEPIT_MINI/target.h
  • src/main/target/FLYCOLORH743/target.c
  • src/main/target/FLYCOLORH743/target.h
  • src/main/target/FLYCOLORH743/target.mk
  • src/main/target/FLYWOOF411/target.h
  • src/main/target/FLYWOOF411HEX/target.h
  • src/main/target/FLYWOOF411V2/target.h
  • src/main/target/FLYWOOF745/target.h
  • src/main/target/FLYWOOF7DUAL/target.h
  • src/main/target/FLYWOOH743PRO/target.c
  • src/main/target/FLYWOOH743PRO/target.h
  • src/main/target/FLYWOOH743PRO/target.mk
  • src/main/target/FOXEERF722DUAL/target.h
  • src/main/target/FOXEERF745_AIO/target.h
  • src/main/target/FOXEERH743/target.c
  • src/main/target/FOXEERH743/target.h
  • src/main/target/FOXEERH743/target.mk
  • src/main/target/FOXEERH743V2/target.c
  • src/main/target/FOXEERH743V2/target.h
  • src/main/target/FOXEERH743V2/target.mk
  • src/main/target/FPVM_BETAFLIGHTF7/target.h
  • src/main/target/GEELANGF411/target.h
  • src/main/target/GEPRCF411_AIO/target.h
  • src/main/target/GEPRCF722BT/target.h
  • src/main/target/GEPRC_F722_AIO/target.h
  • src/main/target/GEPRC_TAKER_H743/target.c
  • src/main/target/GEPRC_TAKER_H743/target.h
  • src/main/target/GEPRC_TAKER_H743/target.mk
  • src/main/target/GEPRC_TAKER_H743MINI/target.c
  • src/main/target/GEPRC_TAKER_H743MINI/target.h
  • src/main/target/GEPRC_TAKER_H743MINI/target.mk
  • src/main/target/GEPRC_TAKER_H743V2/target.c
  • src/main/target/GEPRC_TAKER_H743V2/target.h
  • src/main/target/GEPRC_TAKER_H743V2/target.mk
  • src/main/target/GRAVITYF7/target.h
  • src/main/target/HAKRCF405/target.h
  • src/main/target/HAKRCF411/target.mk
  • src/main/target/HAKRCF722D/target.h
  • src/main/target/HAKRCH743/target.c
  • src/main/target/HAKRCH743/target.h
  • src/main/target/HAKRCH743/target.mk
  • src/main/target/HDZERO_HALO/target.c
  • src/main/target/HDZERO_HALO/target.h
  • src/main/target/HDZERO_HALO/target.mk
  • src/main/target/HELSEL_STRIKERF7/target.mk
  • src/main/target/HGLRCF405/target.h
  • src/main/target/HGLRCF411/target.h
  • src/main/target/HGLRCF722/target.h
  • src/main/target/HGLRC_H743_LITE/target.c
  • src/main/target/HGLRC_H743_LITE/target.h
  • src/main/target/HGLRC_H743_LITE/target.mk
  • src/main/target/HIFIONRCF7/target.h
  • src/main/target/HOBBYWING_XROTORF7CONV/target.h
  • src/main/target/HWH7/target.c
  • src/main/target/HWH7/target.h
  • src/main/target/HWH7/target.mk
  • src/main/target/IFLIGHT_BLITZ_F411RX/target.mk
  • src/main/target/IFLIGHT_BLITZ_H7_PRO/target.c
  • src/main/target/IFLIGHT_BLITZ_H7_PRO/target.h
  • src/main/target/IFLIGHT_BLITZ_H7_PRO/target.mk
  • src/main/target/IFLIGHT_F405_TWING/target.h
  • src/main/target/IFLIGHT_F722_TWING/target.h
  • src/main/target/IFLIGHT_F745_AIO/target.h
  • src/main/target/IFLIGHT_H743_AIO/target.c
  • src/main/target/IFLIGHT_H743_AIO/target.h
  • src/main/target/IFLIGHT_H743_AIO/target.mk
  • src/main/target/IFLIGHT_H743_AIO_V2/target.c
  • src/main/target/IFLIGHT_H743_AIO_V2/target.h
  • src/main/target/IFLIGHT_H743_AIO_V2/target.mk
  • src/main/target/IFLIGHT_H7_TWING/target.c
  • src/main/target/IFLIGHT_H7_TWING/target.h
  • src/main/target/IFLIGHT_H7_TWING/target.mk
  • src/main/target/JHEF405PRO/target.h
  • src/main/target/JHEF411/target.h
  • src/main/target/JHEH743PRO/target.c
  • src/main/target/JHEH743PRO/target.h
  • src/main/target/JHEH743PRO/target.mk
  • src/main/target/JHEH743_AIO/target.c
  • src/main/target/JHEH743_AIO/target.h
  • src/main/target/JHEH743_AIO/target.mk
  • src/main/target/JHEH743_AIO_HD/target.c
  • src/main/target/JHEH743_AIO_HD/target.h
  • src/main/target/JHEH743_AIO_HD/target.mk
  • src/main/target/JHEH743_HD/target.c
  • src/main/target/JHEH743_HD/target.h
  • src/main/target/JHEH743_HD/target.mk
  • src/main/target/KAKUTEF4/target.h
  • src/main/target/KAKUTEF7MINIV3/target.h
  • src/main/target/KAKUTEH7/target.c
  • src/main/target/KAKUTEH7/target.h
  • src/main/target/KAKUTEH7/target.mk
  • src/main/target/KAKUTEH7MINI/target.c
  • src/main/target/KAKUTEH7MINI/target.h
  • src/main/target/KAKUTEH7MINI/target.mk
  • src/main/target/KAKUTEH7V2/target.c
  • src/main/target/KAKUTEH7V2/target.h
  • src/main/target/KAKUTEH7V2/target.mk
  • src/main/target/KONEXH743/target.c
  • src/main/target/KONEXH743/target.h
  • src/main/target/KONEXH743/target.mk
  • src/main/target/LUXH743NDAA/target.c
  • src/main/target/LUXH743NDAA/target.h
  • src/main/target/LUXH743NDAA/target.mk
  • src/main/target/LUXMINIF7/target.h
  • src/main/target/MAMBAF405US/target.h
  • src/main/target/MAMBAF405_2022B/target.h
  • src/main/target/MAMBAF722/target.h
  • src/main/target/MAMBAH743/target.c
  • src/main/target/MAMBAH743/target.h
  • src/main/target/MAMBAH743/target.mk
  • src/main/target/MAMBAH743_2022B/target.c
  • src/main/target/MAMBAH743_2022B/target.h
  • src/main/target/MAMBAH743_2022B/target.mk
  • src/main/target/MATEKF722HD/target.h
  • src/main/target/MATEKF722PX/target.h
  • src/main/target/MATEKH743/target.c
  • src/main/target/MATEKH743/target.h
  • src/main/target/MATEKH743/target.mk
  • src/main/target/MERAKRCF405/target.h
  • src/main/target/MERAKRCF722/target.h
  • src/main/target/MICOAIR743/target.c
  • src/main/target/MICOAIR743/target.h
  • src/main/target/MICOAIR743/target.mk
  • src/main/target/MICOAIR743V2/target.c
  • src/main/target/MICOAIR743V2/target.h
  • src/main/target/MICOAIR743V2/target.mk
  • src/main/target/MINI_H743_HD/target.c
  • src/main/target/MINI_H743_HD/target.h
  • src/main/target/MINI_H743_HD/target.mk
  • src/main/target/NBDBBBLV2/target.mk
  • src/main/target/NBDBBBLV3/target.mk
  • src/main/target/NBD_CRICKETF7/target.h
  • src/main/target/NBD_CRICKETF7V2/target.mk
  • src/main/target/NBD_GALAXYAIO255/target.c
  • src/main/target/NBD_GALAXYAIO255/target.h
  • src/main/target/NBD_GALAXYAIO255/target.mk
  • src/main/target/NBD_INFINITYAIO255/target.h
  • src/main/target/NBD_INFINITYAIOV2PRO/target.h
  • src/main/target/NEUTRONRCH743AIO/target.c
  • src/main/target/NEUTRONRCH743AIO/target.h
  • src/main/target/NEUTRONRCH743AIO/target.mk
  • src/main/target/NEUTRONRCH7BT/target.c
  • src/main/target/NEUTRONRCH7BT/target.h
  • src/main/target/NEUTRONRCH7BT/target.mk
  • src/main/target/OMNIBUSF4FW/target.h
  • src/main/target/OMNIBUSF4V6/target.h
  • src/main/target/PLUMF4/target.h
  • src/main/target/PODIUMF4/target.h
  • src/main/target/PRINCIPIOTH7PI/target.c
  • src/main/target/PRINCIPIOTH7PI/target.h
  • src/main/target/PRINCIPIOTH7PI/target.mk
  • src/main/target/PYRODRONEF4PDB/target.h
  • src/main/target/PYRODRONEF4PDB/target.mk
  • src/main/target/PYRODRONEF7/target.h
  • src/main/target/REVONANO/target.mk
  • src/main/target/RMNOVAH7/target.c
  • src/main/target/RMNOVAH7/target.h
  • src/main/target/RMNOVAH7/target.mk
  • src/main/target/RUSHCORE7/target.h
  • src/main/target/SAKURAH743/target.c
  • src/main/target/SAKURAH743/target.h
  • src/main/target/SAKURAH743/target.mk
  • src/main/target/SDMODELH7/target.c
  • src/main/target/SDMODELH7/target.h
  • src/main/target/SDMODELH7/target.mk
  • src/main/target/SDMODELH7V2/target.c
  • src/main/target/SDMODELH7V2/target.h
  • src/main/target/SDMODELH7V2/target.mk
  • src/main/target/SEQUREH7/target.c
  • src/main/target/SEQUREH7/target.h
  • src/main/target/SEQUREH7/target.mk
  • src/main/target/SEQUREH7V2/target.c
  • src/main/target/SEQUREH7V2/target.h
  • src/main/target/SEQUREH7V2/target.mk
  • src/main/target/SIMPLIFLYH7/target.c
  • src/main/target/SIMPLIFLYH7/target.h
  • src/main/target/SIMPLIFLYH7/target.mk
  • src/main/target/SKYSTARSF7HD/target.h
  • src/main/target/SKYSTARSF7HDPRO/target.h
  • src/main/target/SKYSTARSH7HD/target.c
  • src/main/target/SKYSTARSH7HD/target.h
  • src/main/target/SKYSTARSH7HD/target.mk
  • src/main/target/SOULF4/target.h
  • src/main/target/SPEDIXH743/target.c
  • src/main/target/SPEDIXH743/target.h
  • src/main/target/SPEDIXH743/target.mk
  • src/main/target/SPEEDYBEEF4/target.h
  • src/main/target/SPEEDYBEEF7/target.h
  • src/main/target/SPEEDYBEEF7V2/target.h
  • src/main/target/SPEEDYBEEF7V3/target.h
  • src/main/target/SPEEDYBEEF7V3/target.mk
  • src/main/target/STELLARH7V2/target.c
  • src/main/target/STELLARH7V2/target.h
  • src/main/target/STELLARH7V2/target.mk
  • src/main/target/STM32F411DISCOVERY/target.mk
  • src/main/target/TALONF7DJIHD/target.h
  • src/main/target/TALONF7FUSION/target.h
  • src/main/target/TALONF7V2/target.h
  • src/main/target/TBS_LUCID_H7/target.c
  • src/main/target/TBS_LUCID_H7/target.h
  • src/main/target/TBS_LUCID_H7/target.mk
  • src/main/target/TJRCH743/target.c
  • src/main/target/TJRCH743/target.h
  • src/main/target/TJRCH743/target.mk
  • src/main/target/TMH7/target.c
  • src/main/target/TMH7/target.h
  • src/main/target/TMH7/target.mk
  • src/main/target/TMOTORH743/target.c
  • src/main/target/TMOTORH743/target.h
  • src/main/target/TMOTORH743/target.mk
  • src/main/target/TRANSTECF411/target.mk
  • src/main/target/TRANSTECF411AIO/target.mk
  • src/main/target/TRANSTECF411HD/target.mk
  • src/main/target/TRANSTECF7/target.mk
  • src/main/target/VRRACE/target.mk
  • src/main/target/WDIYH743/target.c
  • src/main/target/WDIYH743/target.h
  • src/main/target/WDIYH743/target.mk
  • src/main/target/WPLV2/target.c
  • src/main/target/WPLV2/target.h
  • src/main/target/WPLV2/target.mk

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

nerdCopter and others added 7 commits June 2, 2026 11:28
AI Generated fix

FLASH_CS_PIN is PC13 on PYRODRONEF4PDB per BF unified-target configs.
The pre-existing TARGET_IO_PORTC mask excluded PC13 (BIT(13)), causing
a compile-time defio validation failure:

  pg/bus_spi.c:131: error: 'defio_error_PC13_is_not_supported_on_TARGET'

Remove BIT(13) from the PORTC exclusion so PC13 is available to the
defio/SPI subsystem as the flash chip-select GPIO. BIT(15) and BIT(14)
remain excluded (RTC oscillator pins). Build verified clean.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…heral instance

SPI6 is SPI_TypeDef* — passing it through SPI_DEV_TO_CFG() performs pointer
arithmetic and emits -Wint-conversion when spiSetBusInstance() expects uint32_t.
Use SPIDEV_6 (the SPIDevice enum) consistent with all other SPI_BUS defines.
SPIDEV_6 does not exist in EF's SPIDevice enum — using it causes a compile error.
Restore SPI6 (warning only) until the enum and H7 SPI driver are extended.
Tracked in issue #NNNN.
Raw SPI6 peripheral pointer caused -Wint-conversion; correct define is
SPIDEV_6 now that the enum and driver support exist (fix/spidev6-h7).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nerdCopter
Copy link
Copy Markdown
Member Author

@coderabbitai, analyze the target changes/additions for appropriateness/defines/resources aligned with EmuFlight architecture, but sourced from https://github.com/betaflight/config

@nerdCopter nerdCopter marked this pull request as ready for review June 3, 2026 20:40
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Get list of files changed in PR `#1233`
gh pr view 1233 --repo emuflight/EmuFlight --json files --jq '.files[].path' | head -120

Length of output: 4061


🏁 Script executed:

#!/bin/bash
# Get total count of changed files
gh pr view 1233 --repo emuflight/EmuFlight --json files --jq '.files | length'

Length of output: 174


🏁 Script executed:

#!/bin/bash
# Look at a sample of the newly added H7 target directories
fd -t d -p 'src/main/target' | grep -iE 'H7|H743|H750' | sort | head -80

Length of output: 2216


🏁 Script executed:

#!/bin/bash
# Get the PR diff for a representative sample - H7 target additions
gh api repos/emuflight/EmuFlight/pulls/1233/files --paginate --jq '.[].filename' | grep -iE 'H7|H743|H750' | sort | head -60

Length of output: 2612


🏁 Script executed:

#!/bin/bash
# Get all changed filenames (full list)
gh api repos/emuflight/EmuFlight/pulls/1233/files --paginate --jq '.[].filename' | sort

Length of output: 12152


🏁 Script executed:

#!/bin/bash
# Sample representative H7 target.h files to check defines
for t in KAKUTEH7V2 MAMBAH743 MATEKH743 FOXEERH743 GEPRC_TAKER_H743 IFLIGHT_H743_AIO JHEH743PRO DARWINH7DUAL NEUTRONRCH743AIO IFLIGHT_H7_TWING; do
  echo "===== $t/target.h ====="
  cat src/main/target/$t/target.h
  echo
done

Length of output: 51243


🏁 Script executed:

#!/bin/bash
# Sample H7 target.mk files to check MCU and flash defines
for t in KAKUTEH7V2 MAMBAH743 MATEKH743 FOXEERH743 GEPRC_TAKER_H743 IFLIGHT_H743_AIO DARWINH7DUAL NEUTRONRCH743AIO IFLIGHT_H7_TWING; do
  echo "===== $t/target.mk ====="
  cat src/main/target/$t/target.mk
  echo
done

Length of output: 6160


🏁 Script executed:

#!/bin/bash
# Check BF config repo for representative H7 targets (use gh to search betaflight/config)
for t in KAKUTEH7V2 MAMBAH743 MATEKH743 FOXEERH743 GEPRC_TAKER_H743 IFLIGHT_H743_AIO DARWINH7DUAL NEUTRONRCH743AIO IFLIGHT_H7_TWING; do
  echo "===== BF config: $t ====="
  gh api repos/betaflight/config/contents/configs/$t/config.h --jq '.content' 2>/dev/null | base64 -d | grep -E 'FLASH|SPI|CS_PIN|ONBOARDFLASH|MCU' | head -30
  echo
done

Length of output: 8184


🏁 Script executed:

#!/bin/bash
# Check flash-audited F4/F7 targets in EF
for t in ALIENFLIGHTNGF7 CLRACINGF7 FPVM_BETAFLIGHTF7 MATEKF722HD ZEEZF7 SPEEDYBEEF7V3 OMNIBUSF4V6; do
  echo "===== $t/target.h (EF) ====="
  grep -E 'FLASH|SPI_INSTANCE|CS_PIN|ONBOARDFLASH' src/main/target/$t/target.h
  echo
done

Length of output: 3658


🏁 Script executed:

#!/bin/bash
# Check BF config for those same F4/F7 flash targets
for t in ALIENFLIGHTNGF7 CLRACINGF7 FPVM_BETAFLIGHTF7 MATEKF722HD ZEEZF7 SPEEDYBEEF7V3 OMNIBUSF4V6; do
  echo "===== BF config: $t ====="
  gh api repos/betaflight/config/contents/configs/$t/config.h --jq '.content' 2>/dev/null | base64 -d | grep -E 'FLASH|SPI|CS_PIN|ONBOARD' | head -20
  echo
done

Length of output: 5174


🏁 Script executed:

#!/bin/bash
# Check a few more H7 targets added - their target.h flash+resource defines
for t in STELLARH7V2 HDZERO_HALO ZEX_ATHENA_MINI ZEX_ATHENA_STD_PRO WPLV2 NBD_GALAXYAIO255 MICOAIR743 MICOAIR743V2; do
  echo "===== $t/target.h ====="
  grep -E 'FLASH|SPI|CS_PIN|ONBOARDFLASH|MCU_|HAL_|USE_' src/main/target/$t/target.h | head -30
  echo
done

Length of output: 6918


🏁 Script executed:

#!/bin/bash
# Check BF config for those additional H7 targets
for t in STELLARH7V2 HDZERO_HALO ZEX_ATHENA_MINI ZEX_ATHENA_STD_PRO WPLV2 NBD_GALAXYAIO255 MICOAIR743 MICOAIR743V2; do
  echo "===== BF config: $t ====="
  gh api repos/betaflight/config/contents/configs/$t/config.h --jq '.content' 2>/dev/null | base64 -d | grep -E 'FLASH|SPI|CS_PIN|ONBOARD' | head -20
  echo
done

Length of output: 4828


🏁 Script executed:

#!/bin/bash
# Check EF common_fc_post.h for STM32H7 MCU defines to verify H7 MCU selection macro
grep -n 'STM32H7\|H743\|H725\|H7XX\|USE_HAL_DRIVER\|MCU_' src/main/target/common_fc_post.h | head -40

Length of output: 428


🏁 Script executed:

#!/bin/bash
# Verify MCU type in H7 target.mk files (should be STM32H743 or STM32H725 etc.)
for t in KAKUTEH7V2 KAKUTEH7MINI BETAFPVH725 MATEKH743 MAMBAH743 MAMBAH743_2022B FOXEERH743 DARWINH7DUAL; do
  echo "===== $t/target.mk MCU line ====="
  grep -E 'MCU_TYPE|STM32H7|FLASH_SIZE' src/main/target/$t/target.mk
  echo
done

Length of output: 721


🏁 Script executed:

#!/bin/bash
# Verify FOXEERH743 SDCARD issue and GEPRC_TAKER_H743 SDIO/SPI contradiction more carefully
echo "=== FOXEERH743 target.h SDCARD grep ==="
grep -n 'SDCARD\|USE_SDCARD' src/main/target/FOXEERH743/target.h

echo ""
echo "=== GEPRC_TAKER_H743 target.h SDCARD grep ==="
grep -n 'SDCARD\|USE_SDCARD' src/main/target/GEPRC_TAKER_H743/target.h

echo ""
echo "=== FOXEERH743 target.mk ==="
cat src/main/target/FOXEERH743/target.mk

echo ""
echo "=== GEPRC_TAKER_H743 target.mk ==="
cat src/main/target/GEPRC_TAKER_H743/target.mk

Length of output: 2904


🏁 Script executed:

#!/bin/bash
# Check BETAFPVH725 MCU type - it uses H725 which may need different target group
echo "=== BETAFPVH725 target.mk ==="
cat src/main/target/BETAFPVH725/target.mk

echo ""
echo "=== BETAFPVH725 target.h MCU/flash ==="
grep -E 'FC_TARGET_MCU|USE_FLASH|FLASH_CS|FLASH_SPI|MCU' src/main/target/BETAFPVH725/target.h

echo ""
echo "=== BF config BETAFPVH725 ==="
gh api repos/betaflight/config/contents/configs/BETAFPVH725/config.h --jq '.content' 2>/dev/null | base64 -d | grep -E 'MCU|FLASH|SPI|CS_PIN' | head -25

echo ""
echo "=== H725/H7 target group in makefile (grep for H725) ==="
grep -rn 'H725_TARGETS\|STM32H725\|h725' src/main/target/ --include='*.mk' | head -20

Length of output: 2470


🏁 Script executed:

#!/bin/bash
# Verify STELLARH7V2 FLASH_CS_PIN and HDZERO_HALO FLASH_CS_PIN/SPI_INSTANCE
echo "=== STELLARH7V2 target.h flash section ==="
grep -n 'FLASH_CS\|FLASH_SPI\|USE_FLASH' src/main/target/STELLARH7V2/target.h

echo ""
echo "=== HDZERO_HALO target.h flash section ==="
grep -n 'FLASH_CS\|FLASH_SPI\|USE_FLASH' src/main/target/HDZERO_HALO/target.h

echo ""
echo "=== MAMBAH743 USE_FLASH_M25P16 duplicate check ==="
grep -n 'USE_FLASH_M25P16\|USE_FLASH' src/main/target/MAMBAH743/target.h

echo ""
echo "=== ZEX_ATHENA_MINI FLASH_CS/SPI ==="
grep -n 'FLASH_CS\|FLASH_SPI\|USE_FLASH' src/main/target/ZEX_ATHENA_MINI/target.h

echo ""
echo "=== ZEX_ATHENA_STD_PRO FLASH_CS/SPI ==="
grep -n 'FLASH_CS\|FLASH_SPI\|USE_FLASH' src/main/target/ZEX_ATHENA_STD_PRO/target.h

echo ""
echo "=== WPLV2 FLASH_CS/SPI ==="
grep -n 'FLASH_CS\|FLASH_SPI\|USE_FLASH' src/main/target/WPLV2/target.h

Length of output: 2586


🏁 Script executed:

#!/bin/bash
# Check ALIENFLIGHTNGF7 full flash section including MAX7456 CS pin conflict check
echo "=== ALIENFLIGHTNGF7 target.h full flash+MAX7456 section ==="
grep -n 'FLASH\|MAX7456\|CS_PIN' src/main/target/ALIENFLIGHTNGF7/target.h

echo ""
echo "=== BF ALIENFLIGHTNGF7 full config ==="
gh api repos/betaflight/config/contents/configs/ALIENFLIGHTNGF7/config.h --jq '.content' 2>/dev/null | base64 -d | head -60

Length of output: 3006


🏁 Script executed:

#!/bin/bash
# Spot check a few more H7 new targets that weren't covered: KAKUTEH7, KAKUTEH7MINI, JHEH743_AIO, BETAFPVH743
for t in KAKUTEH7 KAKUTEH7MINI JHEH743_AIO BETAFPVH743 HGLRC_H743_LITE; do
  echo "===== $t/target.h flash =====";
  grep -E 'FLASH|SDCARD|SPI_INSTANCE|CS_PIN' src/main/target/$t/target.h | head -15
  echo "--- BF config ---"
  gh api repos/betaflight/config/contents/configs/$t/config.h --jq '.content' 2>/dev/null | base64 -d | grep -E 'FLASH|SDCARD|SPI_INSTANCE|CS_PIN' | head -10
  echo
done

Length of output: 5145



@nerdCopter: Here's my cross-reference analysis of the PR's target changes against betaflight/config.


Overall Result: ✅ Largely correct — 3 actionable issues, 1 concern, 1 note

The vast majority of defines are faithful to BF config (chip IDs, FLASH_CS_PIN, FLASH_SPI_INSTANCE, gyro/MAX7456 CS/SPI, voltage scales, UART counts). Here is everything found.


🔴 Issue 1 — FOXEERH743/target.mk: Spurious SDCARD in FEATURES

# Current (wrong):
FEATURES += VCP SDCARD ONBOARDFLASH

# Should be:
FEATURES += VCP ONBOARDFLASH

target.h has no USE_SDCARD, no SDCARD_SPI_CS_PIN, no SD hardware. BF config has none either. The SDCARD flag is a generator artifact.


🔴 Issue 2 — KAKUTEH7/target.h and GEPRC_TAKER_H743/target.h: Conflicting USE_SDCARD_SDIO + USE_SDCARD_SPI

Both files declare USE_SDCARD_SPI at the top (from the device list block) and USE_SDCARD_SDIO again in the SD section, alongside SPI CS/instance pins:

// Line 39  (chip list):
`#define` USE_SDCARD_SPI

// Line 129 (SD section) ← WRONG:
`#define` USE_SDCARD_SDIO
`#define` SDCARD_SPI_CS_PIN   PA15    // KAKUTEH7: PA4
`#define` SDCARD_SPI_INSTANCE SPI3    // KAKUTEH7: SPI1

BF configs for both boards specify USE_SDCARD_SPI only (no SDIO). Remove USE_SDCARD_SDIO from both files.


🟡 Issue 3 — ALIENFLIGHTNGF7/target.h: FLASH_CS_PIN and MAX7456_SPI_CS_PIN both = PB12

`#define` FLASH_CS_PIN         PB12   // on SPI2
`#define` FLASH_SPI_INSTANCE   SPI2

`#define` MAX7456_SPI_CS_PIN   PB12   // on SPI3
`#define` MAX7456_SPI_INSTANCE SPI3

Two devices on different buses sharing the same CS pin would conflict. The BF config grep was truncated before FLASH_CS_PIN — worth manually confirming BF config has this same assignment before treating as actionable. If BF has the same, it's pre-existing hardware design.


⚪ Note 1 — MAMBAH743/target.h: Duplicate USE_FLASH_M25P16 (harmless)

// Line 37 (chip list):
`#define` USE_FLASH_M25P16
// Line 44 (umbrella driver comment):
`#define` USE_FLASH_M25P16    // 16MB Micron M25P16 driver; drives all unless QSPI

Same pattern exists on any H7 target where M25P16 is the actual chip (the generator outputs it in the chip list, then the umbrella line also adds it). Preprocessor duplicate #define of a flag macro is harmless. Cosmetic only.


⚪ Note 2 — BETAFPVH725/target.mk: H723_TARGETS for STM32H725

H723_TARGETS += $(TARGET)  # FC_TARGET_MCU = STM32H725

H725 uses the H723 build group — this is consistent with how H723/H725 share the same core in STM32 families, and BF config confirms STM32H725. Assuming EF's build system maps H723_TARGETS to handle both, this is fine. Confirm H723_TARGETS compiles with H725 silicon in EF's Makefile.


✅ Everything else verified correct against BF config

Target Chip CS Pin SPI Status
KAKUTEH7V2 W25N01G PA4 SPI1
KAKUTEH7MINI W25N01G + W25Q128FV PA4 SPI1
MAMBAH743 M25P16 + W25N01G PA15 SPI3
FOXEERH743 W25Q128FV PA15 SPI3
DARWINH7DUAL W25N01G + W25N02K PD3 SPI3
BETAFPVH725 M25P16 PB6 SPI3
BETAFPVH743 M25P16 PB12 SPI2
STELLARH7V2 M25P16 + W25M02G PE11 SPI4
HDZERO_HALO W25Q128FV PB12 SPI2
HGLRC_H743_LITE W25Q128FV PA15 SPI3
JHEH743_AIO M25P16 PA15 SPI3
JHEH743PRO W25N01G + W25Q128FV PA15 SPI3
ZEX_ATHENA_MINI W25Q128FV PE2 SPI3
ZEX_ATHENA_STD_PRO W25Q128FV PB12 SPI2
WPLV2 W25Q128FV PB12 SPI2
CLRACINGF7 W25Q128FV + W25N01G PB12 SPI2
FPVM_BETAFLIGHTF7 W25Q128FV PE4 SPI4
MATEKF722HD W25Q128FV PB12 SPI2
ZEEZF7 W25N01G PA4 SPI1
SPEEDYBEEF7V3 M25P16 PD2 SPI3
OMNIBUSF4V6 M25P16 PB12 SPI2
NEUTRONRCH743AIO / IFLIGHT_H7_TWING (no CS in BF) ✅ acknowledged
NBD_GALAXYAIO255 / MICOAIR743 / MICOAIR743V2 none
MATEKH743 none (SDIO)

🧠 Learnings used
Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-03-26T16:06:21.396Z
Learning: In the EmuFlight repository (emuflight/EmuFlight), the maintainer (nerdCopter) does not want follow-up GitHub issues created for GitHub Actions SHA pinning or cache key hardening suggestions. The preference is mutable version tags (e.g., v4, v5) and no issue tracking for this topic.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 1189
File: src/main/drivers/bus_spi.c:631-631
Timestamp: 2026-05-15T14:49:26.586Z
Learning: In EmuFlight (emuflight/EmuFlight), all STM32F303 targets in the master branch exceed hardware RAM budget (pre-existing overflow unrelated to any specific PR). As a result, F303 targets do not compile and any F303-specific driver fixes in shared files (e.g., bus_spi.c) should be deferred to a dedicated F3-targeted PR when/if the RAM overflow is resolved.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 1201
File: src/main/target/XILOF4/target.h:151-151
Timestamp: 2026-05-20T19:24:43.018Z
Learning: In the EmuFlight repository, XILOF4 is NOT an EF-only target — it has a matching BF 4.5-maintenance config at `config/configs/XILOF4/config.h` which specifies `DEFAULT_CURRENT_METER_SCALE 118`. The value change from 179 to 118 in `src/main/target/XILOF4/target.h` is intentional and sourced from that BF config.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-04-22T20:55:55.130Z
Learning: In the EmuFlight refactor series (emuflight/EmuFlight, PRs `#1111`, `#1114`, `#1116`, etc.), new-code findings are actionable only if Betaflight 4.5-maintenance does the equivalent. The distinguishing criterion for I2C vs SPI return-value checking: BF 4.5-m's `i2cBusSetInstance` callers do NOT check the return value (so adding a return-value guard in EmuFlight would diverge from BF), whereas BF 4.5-m's `spiSetBusInstance` callers DO check the return (making SPI-side return-check guards in-scope). Adding EF-only documentation or guards to BF-parity functions creates maintenance drift and is out of scope for this series.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-04-23T20:41:53.090Z
Learning: In EmuFlight PR `#1118` (Stage L.2), the correct merge order is: companion targets-only PR `#1119` (macro renames: *_SPI_INSTANCE → *_SPI_BUS across target.h files) must merge first, then `#1118` (call-site migration + forwarder removal in source files). CI failures for undeclared *_SPI_BUS macros in `#1118` standalone are a known merge-order artefact, not code bugs.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-07T16:05:33.483Z
Learning: When responding to nerdCopter on the EmuFlight repository, NEVER generate a coding plan or implementation steps unless the exact keyword "PLAN" appears in their message. Always answer questions directly and concisely.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-04-28T16:46:02.780Z
Learning: EmuFlight (emuflight/EmuFlight) does not maintain 80% docstring coverage codebase-wide. Any automated finding of "docstring coverage X% < 80%" is a pre-existing baseline condition and is out of scope for the BF-parity refactor series (PRs `#1111`, `#1114`, `#1116`, `#1118`, `#1121`, `#1128`, etc.). Do not flag docstring coverage deficiencies in EmuFlight refactor PRs.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-29T15:36:21.638Z
Learning: In `src/main/drivers/flash_w25n.c` (EmuFlight PR `#1204`), all code patterns that appear as potential issues are faithful backports of BF 4.5-maintenance. Specifically: (1) the BBLUT SPI callback `<< 16` shift (line ~1022) is a pre-existing BF bug tracked as EF `#1212` / BF `#15271`; (2) the QuadSPI BBLUT path reading from `in` instead of `bblutBuffer` (line ~1079) is the same BF bug; (3) the outer `#ifdef USE_QUADSPI` wrapping `w25n_programDataLoad`/`w25n_randomProgramDataLoad` is intentional since they are only called from the QuadSPI pageProgramContinue path; (4) `bufferDirty` and `isProgramming` being non-static matches BF 4.5-maintenance. Do not flag any of these as divergences from BF upstream.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-28T20:33:08.829Z
Learning: In EmuFlight, `TIM_USE_CAMERA_CONTROL` is not currently defined in `src/main/drivers/timer.h` even though Betaflight target configs may reference it. For EmuFlight target timer entries that are camera-control pins, use an existing timer usage such as `TIM_USE_ANY` and document the Betaflight camera-control mapping in a comment until EmuFlight adds a dedicated enum value.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-30T17:48:26.388Z
Learning: In EmuFlight (repository: emuflight/EmuFlight), the following bugs were present in the BF 4.5-maintenance flash driver backport but were intentionally fixed in EmuFlight in commit `9f424ae95d` (PR `#1225`), diverging from upstream BF. Do NOT flag these as "BF parity" items in future reviews — they are fixed in EmuFlight:
1. `m25p16_waitForReady` in `src/main/drivers/flash_m25p16.c`: now has a 500 ms timeout; the previous infinite `while (!m25p16_isReady(fdevice));` spin is gone.
2. `m25p16Qspi_vTable` in `src/main/drivers/flash_m25p16.c`: now includes `.configure`; the previous NULL pointer omission is fixed.
3. `w25m_pageProgramBegin` in `src/main/drivers/flash_w25m.c`: now correctly passes `currentWriteAddress` (die-relative) instead of the raw `address` parameter.
4. BBLUT SPI callback in `src/main/drivers/flash_w25n.c`: shift changed from `<< 16` to `<< 8` for both `pba` and `lba` (was tracked as EF issue `#1212` / upstream BF#15271).
5. `w25q128fv_pageProgramContinue` in `src/main/drivers/flash_w25q128fv.c`: now accumulates `bytesWritten`, sets `callbackArg`, and invokes callback in `pageProgramFinish`; the prior uninitialized return is fixed.
The only remaining intentional BF-parity divergences (still present in EmuFlight) are: duplicate `couldBeBusy = true` at lines 231–232 in `flash_m25p16.c`, and the `flashPartitionSet` off-by-one guard (`== FLASH_MAX_PARTITIONS - 1`) in `flash.c`.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-04-24T19:48:08.632Z
Learning: In EmuFlight bus_spi_impl.h (Stage M, PR `#1121`), the header intentionally has no self-contained includes and relies on includer-ordering, because BF 4.5-maintenance bus_spi_impl.h lines 87-92 are identical in structure (same function stubs, no includes, same reliance). This is a pre-existing upstream pattern and should not be flagged as a deficiency in EmuFlight refactor PRs. The issue was filed as EmuFlight `#1122` for upstream tracking.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-28T19:13:36.183Z
Learning: For EmuFlight PR `#1194` STM32H7 support, NAND erase blocking interactions with USB MSC are intentionally tracked under the separate `h7-flash-mashup` scope and should not be treated as blockers for the core STM32H7 port.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-29T16:42:07.214Z
Learning: In EmuFlight H7 target configuration, `USE_FLASH` may be redundant when flash chip macros trigger the cascade in `src/main/target/common_fc_post.h`; for example, `USE_FLASH_W25N01G` implies `USE_FLASH_W25N`, which implies `USE_FLASH`. Do not flag removal of an explicit `USE_FLASH` define when this cascade already applies.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-30T16:48:32.440Z
Learning: In EmuFlight (repository: emuflight/EmuFlight), the flash driver stack in `src/main/drivers/flash_m25p16.c`, `src/main/drivers/flash_w25m.c`, `src/main/drivers/flash_w25n.c`, `src/main/drivers/flash_w25q128fv.c`, and `src/main/drivers/flash.c` was backported from Betaflight 4.5-maintenance (PR `#1225`). The following patterns are intentional BF 4.5-m parity items and should NOT be flagged as bugs:
1. `m25p16_waitForReady` spins with `while (!m25p16_isReady(fdevice));` — no timeout, identical to BF.
2. Duplicate `couldBeBusy = true` assignments at lines 231–232 in `flash_m25p16.c` — identical to BF, both lines intentional.
3. `m25p16Qspi_vTable` (QSPI vtable) is missing `.configure` — identical omission in BF.
4. `w25m_pageProgramBegin` passes the full `address` parameter rather than `currentWriteAddress` — identical to BF at line 207 of `flash_w25m.c`.
5. BBLUT `<< 16` shift overflow in `flash_w25n.c` lines 1015–1016 — pre-existing BF bug filed as BF#15271, tracked in EF as issue `#1212`.
6. `w25q128fv_pageProgramContinue` returns `fdevice->callbackArg` — identical to BF at line 430 of `flash_w25q128fv.c`.
7. `flashPartitionSet` off-by-one guard (`== FLASH_MAX_PARTITIONS - 1`) — identical to BF at line 585 of `flash.c`.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 1225
File: src/main/target/common_fc_post.h:209-223
Timestamp: 2026-05-30T19:05:58.951Z
Learning: In `src/main/target/common_fc_post.h` (EmuFlight), the flash macro normalization block (USE_FLASH_CHIP, USE_FLASH_TOOLS, USE_FLASHFS auto-enable/rollback) is placed *after* the `USE_USB_MSC` pruning check at line ~153. This ordering is intentional BF 4.5-maintenance parity (identical to upstream Betaflight 4.5-maintenance source). Do not flag the interaction between the flash normalization block and the earlier USB_MSC pruning as a bug.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-30T17:59:21.173Z
Learning: In EmuFlight (repository: emuflight/EmuFlight), the `flashPartitionSet` off-by-one guard (`flashPartitions == FLASH_MAX_PARTITIONS - 1` instead of `>=`) in `src/main/drivers/flash.c` is a known BF 4.5-maintenance parity item intentionally retained for PR `#1225`. It is tracked in EmuFlight as issue `#1226` (referencing upstream BF#15279) for post-merge resolution. Do NOT flag it as a new bug during review of this PR — it has zero runtime impact with current single-partition usage and is acknowledged by maintainers.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 1204
File: src/main/drivers/flash_w25n.c:1020-1022
Timestamp: 2026-05-28T20:30:50.733Z
Learning: In `src/main/drivers/flash_w25n.c` (EmuFlight), the `w25n_readBBLUTCallback` function uses `<< 16` shifts when assembling `pba` and `lba` from `rxData` (e.g., `cb_context->bblut->pba = (rxData[0] << 16)|rxData[1]`). This is a known pre-existing Betaflight upstream bug (BF `#15271`) carried in at BF 4.5-maintenance parity. The SPI BBLUT path is dead on all current EmuFlight W25N targets (no NAND flash in production). The fix is deferred to EF issue `#1212` and will be addressed when a W25N + QuadSPI EF target exists. Do not flag this in reviews.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 1225
File: src/main/drivers/flash_w25n.h:23-25
Timestamp: 2026-05-30T19:05:48.233Z
Learning: In EmuFlight (repository: emuflight/EmuFlight), `src/main/drivers/flash_w25n.h` intentionally omits forward `#include` directives for `<stdbool.h>`, `<stdint.h>`, and `flash_impl.h`. This matches the BF 4.5-maintenance upstream source verbatim and is kept for parity. Do not flag the missing includes as an issue in future reviews.

FOXEERH743: remove spurious SDCARD from FEATURES — BF config has no SDCARD
hardware (//TODO #define SDCARD_MODE OFF); generator artifact.

KAKUTEH7, GEPRC_TAKER_H743: remove USE_SDCARD_SDIO — BF configs specify
USE_SDCARD_SPI only; SDIO define conflicts with the SPI CS/instance pins
already present in both files. Found by CodeRabbit review of PR emuflight#1233.
@nerdCopter
Copy link
Copy Markdown
Member Author

AI Generated comment

@coderabbitai, thank you for the thorough cross-reference analysis.

Issue 1 — FOXEERH743 spurious SDCARD in FEATURES: Fixed. BF config confirms //TODO #define SDCARD_MODE OFF — no SD hardware. Removed SDCARD from FEATURES line. ✅

Issue 2 — KAKUTEH7 / GEPRC_TAKER_H743 USE_SDCARD_SDIO conflict: Fixed. Both BF configs specify USE_SDCARD_SPI only. Removed USE_SDCARD_SDIO from both target.h files. ✅

Issue 3 — ALIENFLIGHTNGF7 FLASH_CS_PIN and MAX7456_SPI_CS_PIN both PB12: Verified against BF config — BF config has the same assignment for both pins. This is a pre-existing hardware design in the BF source of truth, not an EF divergence. No change made. ✅ (BF parity)

Note 1 — MAMBAH743 duplicate USE_FLASH_M25P16: Harmless preprocessor duplicate — same flag defined twice is a no-op. Cosmetic only, no change.

Note 2 — BETAFPVH725 H723_TARGETS for STM32H725: Consistent with EF's H7 build system; H725 shares H723 silicon family. No change needed.

All fixes committed in c3890c49a2.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Tip

For best results, initiate chat on the files or code changes.

@nerdCopter: All confirmed — thanks for the thorough resolution notes.

  • Issues 1 & 2 (FOXEERH743 SDCARD in FEATURES; KAKUTEH7 / GEPRC_TAKER_H743 USE_SDCARD_SDIO): fixes verified, no further action needed.
  • Issue 3 (ALIENFLIGHTNGF7 PB12 shared by FLASH_CS_PIN / MAX7456_SPI_CS_PIN): noted as BF parity — recording this for future reviews.
  • Notes 1 & 2: acknowledged, no changes required.

Recording the ALIENFLIGHTNGF7 pin-share as a learning to avoid re-raising it.

(´。• ᵕ •。`) ♡


✏️ Learnings added
Learnt from: nerdCopter
URL: https://github.com/emuflight/EmuFlight/pull/1233

Timestamp: 2026-06-03T20:49:02.493Z
Learning: In EmuFlight `src/main/target/ALIENFLIGHTNGF7/target.h`, both `FLASH_CS_PIN` and `MAX7456_SPI_CS_PIN` are defined as `PB12`. This appears to be a CS pin conflict but is a faithful copy of the Betaflight upstream config (BF `config/configs/ALIENFLIGHTNGF7/config.h`), reflecting the original hardware design. Do not flag it as an EmuFlight divergence or bug in future reviews — it is BF parity.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-30T17:48:26.388Z
Learning: In EmuFlight (repository: emuflight/EmuFlight), the following bugs were present in the BF 4.5-maintenance flash driver backport but were intentionally fixed in EmuFlight in commit `9f424ae95d` (PR `#1225`), diverging from upstream BF. Do NOT flag these as "BF parity" items in future reviews — they are fixed in EmuFlight:
1. `m25p16_waitForReady` in `src/main/drivers/flash_m25p16.c`: now has a 500 ms timeout; the previous infinite `while (!m25p16_isReady(fdevice));` spin is gone.
2. `m25p16Qspi_vTable` in `src/main/drivers/flash_m25p16.c`: now includes `.configure`; the previous NULL pointer omission is fixed.
3. `w25m_pageProgramBegin` in `src/main/drivers/flash_w25m.c`: now correctly passes `currentWriteAddress` (die-relative) instead of the raw `address` parameter.
4. BBLUT SPI callback in `src/main/drivers/flash_w25n.c`: shift changed from `<< 16` to `<< 8` for both `pba` and `lba` (was tracked as EF issue `#1212` / upstream BF#15271).
5. `w25q128fv_pageProgramContinue` in `src/main/drivers/flash_w25q128fv.c`: now accumulates `bytesWritten`, sets `callbackArg`, and invokes callback in `pageProgramFinish`; the prior uninitialized return is fixed.
The only remaining intentional BF-parity divergences (still present in EmuFlight) are: duplicate `couldBeBusy = true` at lines 231–232 in `flash_m25p16.c`, and the `flashPartitionSet` off-by-one guard (`== FLASH_MAX_PARTITIONS - 1`) in `flash.c`.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-30T16:48:32.440Z
Learning: In EmuFlight (repository: emuflight/EmuFlight), the flash driver stack in `src/main/drivers/flash_m25p16.c`, `src/main/drivers/flash_w25m.c`, `src/main/drivers/flash_w25n.c`, `src/main/drivers/flash_w25q128fv.c`, and `src/main/drivers/flash.c` was backported from Betaflight 4.5-maintenance (PR `#1225`). The following patterns are intentional BF 4.5-m parity items and should NOT be flagged as bugs:
1. `m25p16_waitForReady` spins with `while (!m25p16_isReady(fdevice));` — no timeout, identical to BF.
2. Duplicate `couldBeBusy = true` assignments at lines 231–232 in `flash_m25p16.c` — identical to BF, both lines intentional.
3. `m25p16Qspi_vTable` (QSPI vtable) is missing `.configure` — identical omission in BF.
4. `w25m_pageProgramBegin` passes the full `address` parameter rather than `currentWriteAddress` — identical to BF at line 207 of `flash_w25m.c`.
5. BBLUT `<< 16` shift overflow in `flash_w25n.c` lines 1015–1016 — pre-existing BF bug filed as BF#15271, tracked in EF as issue `#1212`.
6. `w25q128fv_pageProgramContinue` returns `fdevice->callbackArg` — identical to BF at line 430 of `flash_w25q128fv.c`.
7. `flashPartitionSet` off-by-one guard (`== FLASH_MAX_PARTITIONS - 1`) — identical to BF at line 585 of `flash.c`.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-29T15:36:21.638Z
Learning: In `src/main/drivers/flash_w25n.c` (EmuFlight PR `#1204`), all code patterns that appear as potential issues are faithful backports of BF 4.5-maintenance. Specifically: (1) the BBLUT SPI callback `<< 16` shift (line ~1022) is a pre-existing BF bug tracked as EF `#1212` / BF `#15271`; (2) the QuadSPI BBLUT path reading from `in` instead of `bblutBuffer` (line ~1079) is the same BF bug; (3) the outer `#ifdef USE_QUADSPI` wrapping `w25n_programDataLoad`/`w25n_randomProgramDataLoad` is intentional since they are only called from the QuadSPI pageProgramContinue path; (4) `bufferDirty` and `isProgramming` being non-static matches BF 4.5-maintenance. Do not flag any of these as divergences from BF upstream.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-30T17:59:21.173Z
Learning: In EmuFlight (repository: emuflight/EmuFlight), the `flashPartitionSet` off-by-one guard (`flashPartitions == FLASH_MAX_PARTITIONS - 1` instead of `>=`) in `src/main/drivers/flash.c` is a known BF 4.5-maintenance parity item intentionally retained for PR `#1225`. It is tracked in EmuFlight as issue `#1226` (referencing upstream BF#15279) for post-merge resolution. Do NOT flag it as a new bug during review of this PR — it has zero runtime impact with current single-partition usage and is acknowledged by maintainers.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 1225
File: src/main/target/common_fc_post.h:209-223
Timestamp: 2026-05-30T19:05:58.951Z
Learning: In `src/main/target/common_fc_post.h` (EmuFlight), the flash macro normalization block (USE_FLASH_CHIP, USE_FLASH_TOOLS, USE_FLASHFS auto-enable/rollback) is placed *after* the `USE_USB_MSC` pruning check at line ~153. This ordering is intentional BF 4.5-maintenance parity (identical to upstream Betaflight 4.5-maintenance source). Do not flag the interaction between the flash normalization block and the earlier USB_MSC pruning as a bug.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-04-22T20:55:55.130Z
Learning: In the EmuFlight refactor series (emuflight/EmuFlight, PRs `#1111`, `#1114`, `#1116`, etc.), new-code findings are actionable only if Betaflight 4.5-maintenance does the equivalent. The distinguishing criterion for I2C vs SPI return-value checking: BF 4.5-m's `i2cBusSetInstance` callers do NOT check the return value (so adding a return-value guard in EmuFlight would diverge from BF), whereas BF 4.5-m's `spiSetBusInstance` callers DO check the return (making SPI-side return-check guards in-scope). Adding EF-only documentation or guards to BF-parity functions creates maintenance drift and is out of scope for this series.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 1204
File: src/main/drivers/flash_m25p16.c:237-238
Timestamp: 2026-05-28T20:30:26.246Z
Learning: In emuflight/EmuFlight, the flash driver backport from BF 4.5-maintenance (PR `#1204`) intentionally preserves verbatim upstream code including the duplicate consecutive assignment `fdevice->couldBeBusy = true;` in `src/main/drivers/flash_m25p16.c` (around lines 237–238). This is by design to maintain exact upstream parity with Betaflight 4.5-maintenance `flash_m25p16.c` lines 231–232, and should not be flagged as a bug in future reviews.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-04-24T19:48:08.632Z
Learning: In EmuFlight bus_spi_impl.h (Stage M, PR `#1121`), the header intentionally has no self-contained includes and relies on includer-ordering, because BF 4.5-maintenance bus_spi_impl.h lines 87-92 are identical in structure (same function stubs, no includes, same reliance). This is a pre-existing upstream pattern and should not be flagged as a deficiency in EmuFlight refactor PRs. The issue was filed as EmuFlight `#1122` for upstream tracking.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-29T16:42:07.214Z
Learning: In EmuFlight H7 target configuration, `USE_FLASH` may be redundant when flash chip macros trigger the cascade in `src/main/target/common_fc_post.h`; for example, `USE_FLASH_W25N01G` implies `USE_FLASH_W25N`, which implies `USE_FLASH`. Do not flag removal of an explicit `USE_FLASH` define when this cascade already applies.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 1225
File: src/main/drivers/flash.c:431-436
Timestamp: 2026-05-30T17:53:24.071Z
Learning: In `src/main/drivers/flash.c` (`flashPartitionSet`), the guard `if (flashPartitions == FLASH_MAX_PARTITIONS - 1)` is an intentional BF 4.5-maintenance parity choice (identical guard exists in Betaflight's flash.c at line 585). EmuFlight currently creates at most one partition (FLASHFS) so the last slot is never reached in practice. The correctness issue has been filed upstream as betaflight/betaflight#15279; EmuFlight will adopt the `>= FLASH_MAX_PARTITIONS` fix only if/when Betaflight merges it. Do not flag this as a bug in future reviews of this codebase.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-01T15:01:31.324Z
Learning: In EmuFlight accgyro_spi_bmi270.c (Stage M.4, PR `#1131`), the `GYRO_EXTI_NO_INT` fallback branch in `bmi270GyroReadRegister` at line 404 (when `detectedEXTI` < `GYRO_EXTI_DETECT_THRESHOLD` before first scheduler read) is intentional BF 4.5-m parity — BF's `bmi270GyroReadRegister` at accgyro_spi_bmi270.c line 406 has the identical branch. Bench-verified on 7 targets including TUNERCF405, SKYSTARSF405AIO (BMI270/F4), and HELIOSPRING (BMI270/F7). Do not flag this as a bug.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 1204
File: src/main/drivers/flash_w25n.c:1020-1022
Timestamp: 2026-05-28T20:30:50.733Z
Learning: In `src/main/drivers/flash_w25n.c` (EmuFlight), the `w25n_readBBLUTCallback` function uses `<< 16` shifts when assembling `pba` and `lba` from `rxData` (e.g., `cb_context->bblut->pba = (rxData[0] << 16)|rxData[1]`). This is a known pre-existing Betaflight upstream bug (BF `#15271`) carried in at BF 4.5-maintenance parity. The SPI BBLUT path is dead on all current EmuFlight W25N targets (no NAND flash in production). The fix is deferred to EF issue `#1212` and will be addressed when a W25N + QuadSPI EF target exists. Do not flag this in reviews.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 1204
File: src/main/drivers/flash.c:431-436
Timestamp: 2026-05-28T20:31:08.837Z
Learning: In emuflight/EmuFlight PR `#1204`, the `flashPartitionSet` function in `src/main/drivers/flash.c` uses the guard `flashPartitions == FLASH_MAX_PARTITIONS - 1` (off-by-one relative to what CodeRabbit flagged). The maintainer accepted this as-is citing BF 4.5-maintenance parity. Note: BF master `flash.c` line 585 reportedly uses `flashPartitions == FLASH_MAX_PARTITIONS` (without the `-1`), so the exact upstream source should be verified if strict parity is required.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-04-04T21:55:50.478Z
Learning: In the EmuFlight project (GitHub: emuflight/EmuFlight), issue `#1106` involves CLI AutoComplete stalls on HELIOSPRING/STRIXF10/MODE2FLUX boards caused by USB VCP write starvation under EXTI preemption. The proposed fix (disabling EXTI via `EXTIEnable()` in `cliEnter()` and re-enabling in `cliExit()`/`cliRebootEx()`) was initially rejected due to apparent "permanent gyro corruption requiring reflash." However, this regression was later identified as a pre-existing configurator CLI/MSP reconnect bug present in the EmuFlight configurator NWjs master branch (not just an Electron/Forge migration bug). The configurator fails to properly re-establish MSP polling after CLI exits; a reflash incidentally forces USB re-enumeration which triggers a clean reconnect, masking the real cause. The EXTI fix itself is logically sound and should be re-evaluated using firmware-independent gyro verification (raw MSP tool) rather than the buggy configurator.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-04-23T20:41:53.090Z
Learning: In EmuFlight PR `#1118` (Stage L.2), the correct merge order is: companion targets-only PR `#1119` (macro renames: *_SPI_INSTANCE → *_SPI_BUS across target.h files) must merge first, then `#1118` (call-site migration + forwarder removal in source files). CI failures for undeclared *_SPI_BUS macros in `#1118` standalone are a known merge-order artefact, not code bugs.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-28T19:13:36.183Z
Learning: For EmuFlight PR `#1194` STM32H7 support, NAND erase blocking interactions with USB MSC are intentionally tracked under the separate `h7-flash-mashup` scope and should not be treated as blockers for the core STM32H7 port.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 1225
File: src/main/drivers/flash_w25n.h:23-25
Timestamp: 2026-05-30T19:05:48.233Z
Learning: In EmuFlight (repository: emuflight/EmuFlight), `src/main/drivers/flash_w25n.h` intentionally omits forward `#include` directives for `<stdbool.h>`, `<stdint.h>`, and `flash_impl.h`. This matches the BF 4.5-maintenance upstream source verbatim and is kept for parity. Do not flag the missing includes as an issue in future reviews.

Two identical defines existed: bare at line 37 and commented at line 44.
Removed the bare one; retained the annotated form with the driver comment
'// 16MB Micron M25P16 driver; drives all unless QSPI' for clarity.
@nerdCopter
Copy link
Copy Markdown
Member Author

@coderabbitai, approve if you truly approve

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

@nerdCopter: Yes — all actionable issues were resolved in c3890c49a2, the cross-reference against betaflight/config checks out across all sampled targets, and the flash define audit is thorough. Approving.

(ノ◕ヮ◕)ノ*:・゚✧


🧠 Learnings used
Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-30T17:48:26.388Z
Learning: In EmuFlight (repository: emuflight/EmuFlight), the following bugs were present in the BF 4.5-maintenance flash driver backport but were intentionally fixed in EmuFlight in commit `9f424ae95d` (PR `#1225`), diverging from upstream BF. Do NOT flag these as "BF parity" items in future reviews — they are fixed in EmuFlight:
1. `m25p16_waitForReady` in `src/main/drivers/flash_m25p16.c`: now has a 500 ms timeout; the previous infinite `while (!m25p16_isReady(fdevice));` spin is gone.
2. `m25p16Qspi_vTable` in `src/main/drivers/flash_m25p16.c`: now includes `.configure`; the previous NULL pointer omission is fixed.
3. `w25m_pageProgramBegin` in `src/main/drivers/flash_w25m.c`: now correctly passes `currentWriteAddress` (die-relative) instead of the raw `address` parameter.
4. BBLUT SPI callback in `src/main/drivers/flash_w25n.c`: shift changed from `<< 16` to `<< 8` for both `pba` and `lba` (was tracked as EF issue `#1212` / upstream BF#15271).
5. `w25q128fv_pageProgramContinue` in `src/main/drivers/flash_w25q128fv.c`: now accumulates `bytesWritten`, sets `callbackArg`, and invokes callback in `pageProgramFinish`; the prior uninitialized return is fixed.
The only remaining intentional BF-parity divergences (still present in EmuFlight) are: duplicate `couldBeBusy = true` at lines 231–232 in `flash_m25p16.c`, and the `flashPartitionSet` off-by-one guard (`== FLASH_MAX_PARTITIONS - 1`) in `flash.c`.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-30T16:48:32.440Z
Learning: In EmuFlight (repository: emuflight/EmuFlight), the flash driver stack in `src/main/drivers/flash_m25p16.c`, `src/main/drivers/flash_w25m.c`, `src/main/drivers/flash_w25n.c`, `src/main/drivers/flash_w25q128fv.c`, and `src/main/drivers/flash.c` was backported from Betaflight 4.5-maintenance (PR `#1225`). The following patterns are intentional BF 4.5-m parity items and should NOT be flagged as bugs:
1. `m25p16_waitForReady` spins with `while (!m25p16_isReady(fdevice));` — no timeout, identical to BF.
2. Duplicate `couldBeBusy = true` assignments at lines 231–232 in `flash_m25p16.c` — identical to BF, both lines intentional.
3. `m25p16Qspi_vTable` (QSPI vtable) is missing `.configure` — identical omission in BF.
4. `w25m_pageProgramBegin` passes the full `address` parameter rather than `currentWriteAddress` — identical to BF at line 207 of `flash_w25m.c`.
5. BBLUT `<< 16` shift overflow in `flash_w25n.c` lines 1015–1016 — pre-existing BF bug filed as BF#15271, tracked in EF as issue `#1212`.
6. `w25q128fv_pageProgramContinue` returns `fdevice->callbackArg` — identical to BF at line 430 of `flash_w25q128fv.c`.
7. `flashPartitionSet` off-by-one guard (`== FLASH_MAX_PARTITIONS - 1`) — identical to BF at line 585 of `flash.c`.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-29T15:36:21.638Z
Learning: In `src/main/drivers/flash_w25n.c` (EmuFlight PR `#1204`), all code patterns that appear as potential issues are faithful backports of BF 4.5-maintenance. Specifically: (1) the BBLUT SPI callback `<< 16` shift (line ~1022) is a pre-existing BF bug tracked as EF `#1212` / BF `#15271`; (2) the QuadSPI BBLUT path reading from `in` instead of `bblutBuffer` (line ~1079) is the same BF bug; (3) the outer `#ifdef USE_QUADSPI` wrapping `w25n_programDataLoad`/`w25n_randomProgramDataLoad` is intentional since they are only called from the QuadSPI pageProgramContinue path; (4) `bufferDirty` and `isProgramming` being non-static matches BF 4.5-maintenance. Do not flag any of these as divergences from BF upstream.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-06-03T20:49:02.493Z
Learning: In EmuFlight `src/main/target/ALIENFLIGHTNGF7/target.h`, both `FLASH_CS_PIN` and `MAX7456_SPI_CS_PIN` are defined as `PB12`. This appears to be a CS pin conflict but is a faithful copy of the Betaflight upstream config (BF `config/configs/ALIENFLIGHTNGF7/config.h`), reflecting the original hardware design. Do not flag it as an EmuFlight divergence or bug in future reviews — it is BF parity.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-30T17:59:21.173Z
Learning: In EmuFlight (repository: emuflight/EmuFlight), the `flashPartitionSet` off-by-one guard (`flashPartitions == FLASH_MAX_PARTITIONS - 1` instead of `>=`) in `src/main/drivers/flash.c` is a known BF 4.5-maintenance parity item intentionally retained for PR `#1225`. It is tracked in EmuFlight as issue `#1226` (referencing upstream BF#15279) for post-merge resolution. Do NOT flag it as a new bug during review of this PR — it has zero runtime impact with current single-partition usage and is acknowledged by maintainers.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 1225
File: src/main/target/common_fc_post.h:209-223
Timestamp: 2026-05-30T19:05:58.951Z
Learning: In `src/main/target/common_fc_post.h` (EmuFlight), the flash macro normalization block (USE_FLASH_CHIP, USE_FLASH_TOOLS, USE_FLASHFS auto-enable/rollback) is placed *after* the `USE_USB_MSC` pruning check at line ~153. This ordering is intentional BF 4.5-maintenance parity (identical to upstream Betaflight 4.5-maintenance source). Do not flag the interaction between the flash normalization block and the earlier USB_MSC pruning as a bug.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-04-22T20:55:55.130Z
Learning: In the EmuFlight refactor series (emuflight/EmuFlight, PRs `#1111`, `#1114`, `#1116`, etc.), new-code findings are actionable only if Betaflight 4.5-maintenance does the equivalent. The distinguishing criterion for I2C vs SPI return-value checking: BF 4.5-m's `i2cBusSetInstance` callers do NOT check the return value (so adding a return-value guard in EmuFlight would diverge from BF), whereas BF 4.5-m's `spiSetBusInstance` callers DO check the return (making SPI-side return-check guards in-scope). Adding EF-only documentation or guards to BF-parity functions creates maintenance drift and is out of scope for this series.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 1204
File: src/main/drivers/flash_m25p16.c:237-238
Timestamp: 2026-05-28T20:30:26.246Z
Learning: In emuflight/EmuFlight, the flash driver backport from BF 4.5-maintenance (PR `#1204`) intentionally preserves verbatim upstream code including the duplicate consecutive assignment `fdevice->couldBeBusy = true;` in `src/main/drivers/flash_m25p16.c` (around lines 237–238). This is by design to maintain exact upstream parity with Betaflight 4.5-maintenance `flash_m25p16.c` lines 231–232, and should not be flagged as a bug in future reviews.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-04-24T19:48:08.632Z
Learning: In EmuFlight bus_spi_impl.h (Stage M, PR `#1121`), the header intentionally has no self-contained includes and relies on includer-ordering, because BF 4.5-maintenance bus_spi_impl.h lines 87-92 are identical in structure (same function stubs, no includes, same reliance). This is a pre-existing upstream pattern and should not be flagged as a deficiency in EmuFlight refactor PRs. The issue was filed as EmuFlight `#1122` for upstream tracking.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-29T16:42:07.214Z
Learning: In EmuFlight H7 target configuration, `USE_FLASH` may be redundant when flash chip macros trigger the cascade in `src/main/target/common_fc_post.h`; for example, `USE_FLASH_W25N01G` implies `USE_FLASH_W25N`, which implies `USE_FLASH`. Do not flag removal of an explicit `USE_FLASH` define when this cascade already applies.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 1225
File: src/main/drivers/flash_w25n.h:23-25
Timestamp: 2026-05-30T19:05:48.233Z
Learning: In EmuFlight (repository: emuflight/EmuFlight), `src/main/drivers/flash_w25n.h` intentionally omits forward `#include` directives for `<stdbool.h>`, `<stdint.h>`, and `flash_impl.h`. This matches the BF 4.5-maintenance upstream source verbatim and is kept for parity. Do not flag the missing includes as an issue in future reviews.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 1204
File: src/main/drivers/flash.c:431-436
Timestamp: 2026-05-28T20:31:08.837Z
Learning: In emuflight/EmuFlight PR `#1204`, the `flashPartitionSet` function in `src/main/drivers/flash.c` uses the guard `flashPartitions == FLASH_MAX_PARTITIONS - 1` (off-by-one relative to what CodeRabbit flagged). The maintainer accepted this as-is citing BF 4.5-maintenance parity. Note: BF master `flash.c` line 585 reportedly uses `flashPartitions == FLASH_MAX_PARTITIONS` (without the `-1`), so the exact upstream source should be verified if strict parity is required.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 1225
File: src/main/drivers/flash.c:431-436
Timestamp: 2026-05-30T17:53:24.071Z
Learning: In `src/main/drivers/flash.c` (`flashPartitionSet`), the guard `if (flashPartitions == FLASH_MAX_PARTITIONS - 1)` is an intentional BF 4.5-maintenance parity choice (identical guard exists in Betaflight's flash.c at line 585). EmuFlight currently creates at most one partition (FLASHFS) so the last slot is never reached in practice. The correctness issue has been filed upstream as betaflight/betaflight#15279; EmuFlight will adopt the `>= FLASH_MAX_PARTITIONS` fix only if/when Betaflight merges it. Do not flag this as a bug in future reviews of this codebase.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 1204
File: src/main/drivers/flash_w25n.c:1020-1022
Timestamp: 2026-05-28T20:30:50.733Z
Learning: In `src/main/drivers/flash_w25n.c` (EmuFlight), the `w25n_readBBLUTCallback` function uses `<< 16` shifts when assembling `pba` and `lba` from `rxData` (e.g., `cb_context->bblut->pba = (rxData[0] << 16)|rxData[1]`). This is a known pre-existing Betaflight upstream bug (BF `#15271`) carried in at BF 4.5-maintenance parity. The SPI BBLUT path is dead on all current EmuFlight W25N targets (no NAND flash in production). The fix is deferred to EF issue `#1212` and will be addressed when a W25N + QuadSPI EF target exists. Do not flag this in reviews.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-05-28T19:13:36.183Z
Learning: For EmuFlight PR `#1194` STM32H7 support, NAND erase blocking interactions with USB MSC are intentionally tracked under the separate `h7-flash-mashup` scope and should not be treated as blockers for the core STM32H7 port.

Learnt from: nerdCopter
Repo: emuflight/EmuFlight PR: 0
File: :0-0
Timestamp: 2026-04-23T20:41:53.090Z
Learning: In EmuFlight PR `#1118` (Stage L.2), the correct merge order is: companion targets-only PR `#1119` (macro renames: *_SPI_INSTANCE → *_SPI_BUS across target.h files) must merge first, then `#1118` (call-site migration + forwarder removal in source files). CI failures for undeclared *_SPI_BUS macros in `#1118` standalone are a known merge-order artefact, not code bugs.
✅ Action performed

Comments resolved and changes approved.

@nerdCopter nerdCopter marked this pull request as draft June 3, 2026 21:00
@nerdCopter nerdCopter marked this pull request as ready for review June 4, 2026 13:36
@nerdCopter nerdCopter merged commit 35be7c3 into emuflight:master Jun 4, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant